using System.Collections.Generic;
using System.Text;

namespace OracleInternal.SqlAndPlsqlParser.LocalParsing
{
	internal class OracleLpIntervalExpression : OracleLpExpression
	{
		protected OracleLpIntervalExpressionType m_vIntervalExpessionType;

		public OracleLpIntervalExpressionType IntervalExpessionType
		{
			get
			{
				return m_vIntervalExpessionType;
			}
			set
			{
				m_vIntervalExpessionType = value;
			}
		}

		public OracleLpIntervalExpression(OracleLpStatementElement parent)
			: base(parent)
		{
			m_vExpressionType = OracleLpExpressionType.INTERVAL_EXPRESSION;
		}

		public override void EvaluateDatatype()
		{
		}

		public override IList<OracleLpExpression> GetAllTerminalExpressions()
		{
			if (m_vAllTerminalExpressions == null)
			{
				m_vAllTerminalExpressions = new List<OracleLpExpression>();
				m_vAllTerminalExpressions.Add(this);
			}
			return m_vAllTerminalExpressions;
		}

		internal override void ToString(StringBuilder sb)
		{
			base.ToString(sb);
			sb.Append("  Interval expression: ");
			sb.Append("  Type: ");
			switch (m_vIntervalExpessionType)
			{
			case OracleLpIntervalExpressionType.YEAR_TO_MONTH:
				sb.Append("YEAR TO MONTH");
				break;
			case OracleLpIntervalExpressionType.DAY_TO_SECOND:
				sb.Append("DAY TO SECOND");
				break;
			}
			sb.Append(m_vText.Fragment);
		}
	}
}
